
// 为所有对象添加方法print，打印对象的键值对

Object.prototype.print = function () {
    for (var key in this) {
        if (this.hasOwnProperty(key)) { console.log(key + ':',this[key]); }
    }
}


var obj1 = {
    a: 1,
    b: 2
}

obj1.print()

var obj2 = {
    0: 1,
    1: 2
}

obj2.print()